<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style type="text/css">
			#div1{
				height: 200px;
				width: 200px;
				background-color: red;
			}
			
			button{
				margin-top: 10px;
				height: 50px;
				width: 100px;
				font-size: 30px;
			}
		</style>
	</head>
	<body>
		<div id="div1"></div>
		<button onclick="displayOrHide()">隐藏</button>
	</body>
	<script type="text/javascript">
		var showFlag = true;
		function displayOrHide(){
			if(showFlag){
				document.getElementById("div1").style.display = "none";
				showFlag = false;
				document.getElementsByTagName("button")[0].innerText = "显示";
			}else{
				document.getElementById("div1").style.display = "block";
				showFlag = true;
				document.getElementsByTagName("button")[0].innerText = "隐藏";
			}
		}
	</script>
</html>
